package com.fable.sp.core.domain;

import org.springframework.util.StringUtils;

import java.io.Serializable;

/**
 * .
 *
 * @author stormning on 16/7/30.
 */
public class Border implements Serializable {

    public static Border DEFAULT = new Border(1, BorderStyle.SOLID, "#DDD");
    private Integer width = 0;
    private BorderStyle style = BorderStyle.SOLID;
    private String color;

    public Border() {
    }

    public Border(Integer width, BorderStyle style, String color) {
        this.width = width;
        this.style = style;
        this.color = color;
    }

    public Integer getWidth() {
        return width;
    }

    public void setWidth(Integer width) {
        this.width = width;
    }

    public BorderStyle getStyle() {
        return style;
    }

    public void setStyle(BorderStyle style) {
        this.style = style;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        if (width != null && width >= 0) {
            builder.append(width).append("px");
        }
        if (style != null) {
            builder.append(" ").append(style.getStyleString());
        }
        if (StringUtils.hasText(color)) {
            builder.append(" ").append(color);
        }
        builder.append(";");
        return builder.toString();
    }
}
